package com.alcatel_lucent.osp.model;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created with IntelliJ IDEA.
 * User: guoshunw
 * Date: 13-8-23
 * Time: 下午6:13
 */

@Entity
@Table(name = "TYPE")
public class Type extends BaseEntity {
    private String name;

    private Collection<Category> categories;

    @JoinTable(
            name = "CATEGORY_TYPE",
            inverseJoinColumns = @JoinColumn(name = "CATEGORY_ID"),
            joinColumns = @JoinColumn(name = "TYPE_ID")
    )
    @ManyToMany()
    public Collection<Category> getCategories() {
        return categories;
    }

    public void setCategories(Collection<Category> categories) {
        this.categories = categories;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "IdTypeGenerator")
    @SequenceGenerator(name = "IdTypeGenerator", sequenceName = "ID_TYPE", allocationSize = 20)
    @Override
    public Long getId() {
        return super.getId();
    }

    public Type() {
    }

    public Type(String name) {
        this.name = name;
    }

    @Column(name = "NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
